import {hrAjax as proFetch} from 'src/hrpub/common/utils/utils';
import {toast} from 'nc-lightapp-front';

export default function afterFormEdit(areaCode, key, model, oldValue, index) {
    const {orgVal, form} = this.props;
    let postData = {
        pk_org: orgVal.refpk,
        key,
        model: form.getAllFormValue(areaCode)
    };

    return proFetch({
        url: '/nccloud/hrtrn/partrds/PartRdsAddAfterEditAction.do',
        body: postData,
    })
        .then((res) => {
            if (res.success) {
                if (res.data.errMsg) {
                    toast({
                        color: 'error',
                        content: res.data.errMsg
                    })
                } else {
                    form.setAllFormValue({'parttime': res.data.formData[areaCode]});
                    if (res.data.disableItem) {
                        form.setFormItemsDisabled(areaCode, res.data.disableItem)
                    }
                }
            }
        });
}
